Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: fix mypy errors #977

Merged
merged 3 commits into from
Feb 9, 2024
Merged

CI: fix mypy errors #977

merged 3 commits into from
Feb 9, 2024

Conversation

shanedsnyder
Copy link
Contributor

We're getting errors like this in the PyDarshan CI now related to the mypy step:

darshan/tests/test_summary.py:180: error: Module has no attribute "has_log_repo"  [attr-defined]
darshan/tests/test_report.py:32: error: Module has no attribute "has_log_repo"  [attr-defined]

which I think is caused by injecting variables into pytest (and later referencing them in tests), like in conftest.py:

def pytest_configure():
    pytest.has_log_repo = has_log_repo

As a temporary workaround, just remove offending pytest skipif decorators -- it looks like this modification just works and still properly skips tests due to not having the log file repo. The only downside is the skip reason is less helpful now, e.g. instead of:

SKIPPED [1] darshan/tests/test_report.py:32: missing darshan_logs

we now get:

SKIPPED [1] darshan/tests/test_report.py:32: got empty parameter set ['log_filepath'], function test_jobid_type_all_logs_repo_files at /home/shane/software/darshan/darshan-python/darshan-util/pydarshan/darshan/tests/test_report.py:31

I'm open to alternative solutions. I couldn't come up with anything that allows us to detect the presence of the log repo from inside a decorator like that.

Copy link
Collaborator

@tylerjereddy tylerjereddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might have a slight preference for leaving the markers and disabling the error code:

--- a/darshan-util/pydarshan/mypy.ini
+++ b/darshan-util/pydarshan/mypy.ini
@@ -45,3 +45,6 @@ ignore_missing_imports = True
 
 [mypy-darshan.backend.cffi_backend]
 ignore_errors = True
+
+[mypy-darshan.tests.*]
+disable_error_code = attr-defined

I think what happened is that pytest 8.0.0 was released with more typing support, since we didn't change much on our end.

@shanedsnyder
Copy link
Contributor Author

That works for me, too, thanks for the suggestion. I've just pushed in that change and will merge assuming everything passes.

@shanedsnyder shanedsnyder merged commit 82a78b7 into main Feb 9, 2024
21 checks passed
@tylerjereddy tylerjereddy deleted the snyder/mypy-has-log-repo-attr branch March 1, 2024 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants